home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_MakeMenu.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  1KB  |  56 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. **
  6. **  :ts=4
  7. */
  8.  
  9. #include "gtlayout_global.h"
  10.  
  11. #ifdef DO_MENUS
  12.  
  13.     /* LTP_MakeMenu(RootMenu *Root,MenuNode *Menu,struct NewMenu *Template):
  14.      *
  15.      *    Create a single menu and fill it in.
  16.      */
  17.  
  18. MenuNode * __regargs
  19. LTP_MakeMenu(RootMenu *Root,MenuNode *Menu,struct NewMenu *Template)
  20. {
  21.         // If none is provided, roll our own
  22.  
  23.     if(!Menu)
  24.         Menu = (MenuNode *)AsmAllocPooled(Root -> Pool,sizeof(MenuNode),SysBase);
  25.  
  26.     if(Menu)
  27.     {
  28.         STRPTR Label = Template -> nm_Label;
  29.  
  30.             // Use the screen font for the layout
  31.  
  32.         SetFont(&Root -> RPort,Root -> DrawInfo -> dri_Font);
  33.  
  34.             // Fill in the size
  35.  
  36.         Menu -> Menu . Width    = TextLength(&Root -> RPort,Label,strlen(Label)) + 6;
  37.         Menu -> Menu . Height    = Root -> Screen -> BarHeight;
  38.  
  39.         Menu -> Menu . MenuName    = (BYTE *)Label;
  40.         Menu -> UserData        = Template -> nm_UserData;
  41.  
  42.             // Return to the original font
  43.  
  44.         SetFont(&Root -> RPort,Root -> Font);
  45.  
  46.             // Take care of the only valid bit
  47.  
  48.         if(!(Template -> nm_Flags & NM_MENUDISABLED))
  49.             Menu -> Menu . Flags = MENUENABLED;
  50.     }
  51.  
  52.     return(Menu);
  53. }
  54.  
  55. #endif    /* DO_MENUS */
  56.